class Solution 
{
public:
    int minCost(vector<vector<int>>& costs) 
    {
        int row = costs.size(), col = 3;
        vector<vector<int>> vv(row+1, vector<int>(col));

        for(int i=1; i<=row; i++)
        {         
            vv[i][0] = min(vv[i-1][1], vv[i-1][2]) + costs[i-1][0];
            vv[i][1] = min(vv[i-1][0], vv[i-1][2]) + costs[i-1][1];
            vv[i][2] = min(vv[i-1][1], vv[i-1][0]) + costs[i-1][2];          
        }

        return min({vv[row][0],vv[row][1],vv[row][2]});
    }
};